<template>
    <h1 class="font-weight-semibold">人声和伴奏分离</h1>
    <h6 class="font-weight-normal text-muted pb-3">臻纯 可以分离音频中的语音和音乐部分</h6>

    <form id="audioForm" action="/jobs/add" enctype="multipart/form-data" method="POST">

        <div class="upload-block">
            <div class="drag-area" @dragover="handleDragOver" @dragleave="handleDragLeave" @drop="handleDrop">
                <header>拖放以上传文件</header>
                <span>或</span>
                <div style="display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 10px 0px">
                    <button type="button" class="btn btn-primary btn-lg" @click="chooseFile">点击上传文件</button>
                    <input type="file" id="fileInput" style="display: none" @change="handleFileInput" />
                </div>
            </div>



            <div class="settings-sidebar">
                <div class="form-group row">
                    <label for="sep_type" class="col-sm-3 control-label">
                        <span>分离类型</span>
                    </label>
                    <div id="div_sep_type" class="col-sm-9" style="white-space: normal;">
                        <select id="sep_type" name="sep_type" class="form-control selectpicker">


                            <option value="">Demucs4 HT (vocals, drums, bass, other)</option>

                            <option value="">MDX23C (vocals, instrumental)</option>

                            <option value="">MDX B (vocals, instrumental)</option>


                        </select>
                    </div>

                </div>

                <div class="form-group row">
                    <label for="mod_type" class="col-sm-3 control-label">
                        <span>模型选择</span>
                    </label>

                    <div id="div_mod_type" class="col-sm-9" style="white-space: normal;">
                        <select name="mod_type" id="mod_type" class="form-control selectpicker">
                            <option value="">htdemucs_ft(High)</option>
                        </select>

                    </div>
                </div>



                <div class="form-group row">
                    <label class="col-sm-3">
                        <span>发布到 <a href="http://localhost:8080/#/sample" target="_blank"
                                title="分离的结果将在示例页上保留几天"><u>示例页</u></a></span>
                    </label>
                    <div id="demo_page" class="col-sm-9 d-flex align-items-center justify-content-start">
                        <div class="switch-container">
                            <label class="switch">
                                <input type="checkbox">
                                <span class="slider round"></span>
                            </label>
                        </div>

                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <div id="recaptcha_element"> </div>
                    </div>
                </div>
                <div class="form-group row">
                    <input class="btn btn-primary btn-lg btn-block" type="submit" id="submitAudio" name="addfile"
                        value="分离">
                </div>
            </div>
        </div>
    </form>
</template>

<script>


export default {

    methods: {
        handleDragOver(event) {
            event.preventDefault();
            event.currentTarget.classList.add('active');
        },
        handleDragLeave(event) {
            event.currentTarget.classList.remove('active');
        },
        handleDrop(event) {
            event.preventDefault();
            event.currentTarget.classList.remove('active');
            const files = event.dataTransfer.files;
            if (files.length > 0) {
                this.handleFiles(files);
            }
        },
        chooseFile() {
            const fileInput = document.getElementById('fileInput');
            fileInput.click();
        },
        handleFileInput(event) {
            const files = event.target.files;
            this.handleFiles(files);
        },
        handleFiles(files) {
            console.log(files);
            alert('已成功上传文件')
            // 在这里执行上传文件的操作或其他处理
        }
    }

};



</script>

<style scoped>
/* .upload-demo {
    margin-top: 20px;
} */

.upload-block {
    display: flex;
    justify-content: space-evenly;
    flex-wrap: wrap;
}

.font-weight-semibold {
    font-weight: 600;
}




.settings-sidebar {
    padding: 8px 0;
    display: flex;
    width: 500px;
    justify-content: space-around;
    flex-direction: column;
}

h1 {
    font-size: 40px;
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
    margin-bottom: 0.5rem;
    font-weight: 500;
    line-height: 1.2;
}

.text-muted {
    color: #6e6e6e !important;
}

.font-weight-normal {
    font-weight: 400 !important;
}

.pb-3,
.py-3 {
    padding-bottom: 1rem !important;
}

h6 {
    font-size: 17px;
}

.drag-area {
    border: 2px dashed #0176b3;
    color: #0176b3;
    height: 350px;
    width: 500px;
    display: flex;
    position: relative;
    border-radius: 5px;
    align-items: center;
    flex-direction: column;
    justify-content: space-around;
}

.drag-area header {
    font-size: 30px;
    font-weight: 500;
}

.drag-area span {
    font-size: 30px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 2.5rem;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.row {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 0;
    display: flex;
    flex-wrap: wrap;
    margin-top: calc(-1 * var(--bs-gutter-y));
    margin-right: calc(-0.5 * var(--bs-gutter-x));
    margin-left: calc(-0.5 * var(--bs-gutter-x));
}

.control-label {
    align-items: center;
}

.col-sm-3 {
    flex: 0 0 25%;
    max-width: 25%;
}

.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12,
.col,
.col-auto,
.col-sm-1,
.col-sm-2,
.col-sm-3,
.col-sm-4,
.col-sm-5,
.col-sm-6,
.col-sm-7,
.col-sm-8,
.col-sm-9,
.col-sm-10,
.col-sm-11,
.col-sm-12,
.col-sm,
.col-sm-auto,
.col-md-1,
.col-md-2,
.col-md-3,
.col-md-4,
.col-md-5,
.col-md-6,
.col-md-7,
.col-md-8,
.col-md-9,
.col-md-10,
.col-md-11,
.col-md-12,
.col-md,
.col-md-auto,
.col-lg-1,
.col-lg-2,
.col-lg-3,
.col-lg-4,
.col-lg-5,
.col-lg-6,
.col-lg-7,
.col-lg-8,
.col-lg-9,
.col-lg-10,
.col-lg-11,
.col-lg-12,
.col-lg,
.col-lg-auto,
.col-xl-1,
.col-xl-2,
.col-xl-3,
.col-xl-4,
.col-xl-5,
.col-xl-6,
.col-xl-7,
.col-xl-8,
.col-xl-9,
.col-xl-10,
.col-xl-11,
.col-xl-12,
.col-xl,
.col-xl-auto {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

.col-sm-9 {
    flex: 0 0 75%;
    max-width: 75%;
}

label {
    display: inline-block;
    margin-bottom: 0.5rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--bs-body-color);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--bs-body-bg);
    background-clip: padding-box;
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.settings-sidebar a {
    display: block;
}

a {
    color: #186eb1;
    text-decoration: none;
    background-color: transparent;
}

.switch-container {
    display: inline-block;
    vertical-align: middle;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #2196F3;
}

input:focus+.slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked+.slider:before {
    -webkit-transform: translateX(29px);
    -ms-transform: translateX(29px);
    transform: translateX(29px);
}
</style>
